<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>收文详情</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link th:href="@{/res/notice/lib/weui.min.css}" rel="stylesheet"/>
    <link th:href="@{/res/notice/css/jquery-weui.css}" rel="stylesheet"/>
    <link th:href="@{/res/notice/css/font-awesome.css?v=4.4.0}" rel="stylesheet"/>
    <link th:href="@{/res/notice/css/common.css}" rel="stylesheet"/>
</head>
<body class="bgline3 pb70">

<header class='demos-header bgwhite mb5 ptb10'>
    <h3 class="tc blue" th:text="${notice.noticeTheme}"></h3>
</header>

<article class="weui-article bgwhite">
    <!--时间-->
    <p>
        <span class="bold">发送时间：</span>
        <small th:text="${#dates.format(notice.noticeSendingTime,'yyyy-MM-dd HH:mm')}"></small>
    </p>
    <!--类型-->
    <p>
        <span class="bold">通知类型：</span>
        <small th:text="${@dict.getValueByTableAndKey('sys_notice_type',notice.noticeType)}"></small>
    </p>
    <!--发件人-->
    <p>
        <span class="bold">发件人：</span>
        <small th:text="${@dingUser.getNoticeSenderValue(notice.noticeSender)}"></small>
    </p>
    <!--署名-->
    <p>
        <span class="bold">署名：</span>
        <small th:text="${notice.noticeSignature}"></small></p>
    <!--内容-->
    <!--<p>
        <span class="bold">内容：</span>
        <small th:text="${notice.noticeContent}"></small>
    </p>-->
    <!--附件-->
    <p id="down-button">
        <span class="bold">附件：</span>
        <small th:text="${file.fileName}"></small>
        <a class="blue ml5 ft12 bold italic" onclick="downloadThis()">
            <i class="fa fa-mouse-pointer"></i>下载
        </a>
    </p>
    <!--参会人员-->
    <div id="sign-button">
        <span class="bold">参会人员：</span>
        <div id="sign-yes">
            <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary open-popup"
               data-target="#conferenceRegistrationPopup">
                <i class="fa fa-hand-paper-o"></i> 会议报名
            </a>
        </div>
        <div id="sign-edit">
            <small th:text="${addressee.participantsName}"></small>
            <a href="javascript:;" class="ml10 bgblue white plr5 tc inblock ft12 radius4 open-popup"
               data-target="#conferenceRegistrationPopup">
                <i></i>修改
            </a>
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    <!--内容-->
    <!--<p th:text="${notice.noticeContent}"></p>-->
    <div class="hr-line-dashed"></div>
    <!--通知回复-->
    <div class="panel panel-info">
        <div class="panel-heading">
            <i class="fa fa-info-circle"></i> 以下为通知回复
        </div>
        <div th:each="response : ${response}" class="panel-body">
            <form class="form-horizontal m-t">
                <!--时间内容-->
                <div class="form-group">
                    <p>
                        <span class="bold">回复时间：</span>
                        <small th:text="${#dates.format(response.responseTime,'yyyy-MM-dd HH:mm')}"></small>
                    </p>
                    <p>
                        <span class="bold">回复人：</span>
                        <small th:text="${@dingUser.getAddresseeNameValue(response.responseSender)}"></small>
                    </p>
                    <p>
                        <span class="bold">回复内容：</span>
                        <small th:text="${response.responseContent}"></small>
                    </p>
                </div>
                <!--附件-->
                <p>
                    <span class="bold">附件：</span>
                    <small  th:text="${response.fileName}"></small>
                    <a class="blue ml5 ft12 bold italic" th:onclick="downloadThat([[${response.fileRoute}]]);">
                        <i class="fa fa-mouse-pointer"></i>下载
                    </a>
                </p>
            </form>
        </div>
    </div>
</article>

<!--<div class="bgpart w100 ptb10 fixed btm0 flex around alcenter topshadow">
    <a class="w45 weui-btn weui-btn_plain-primary open-popup"
       th:href="@{'/mobile/notice/toForward/'+ ${notice.noticeId} + '?token='+ ${token}} ">转发</a>
    <a class="w45 weui-btn weui-btn_primary open-popup" href="javascript:" data-target="#replyPopup"
       style="margin-top: 0;">回复</a>
</div>-->

<!-- 会议报名Popup-->
<div id="conferenceRegistrationPopup" class='weui-popup__container popup-bottom'>
    <form class="form-horizontal m" id="form-signUp-add">
        <div class="weui-popup__overlay">
            <input name="addresseeId" th:field="${addressee.addresseeId}" type="hidden">
            <input name="noticeId" th:field="${addressee.noticeId}" type="hidden">
            <input name="addresseeName" th:field="${addressee.addresseeName}" type="hidden">
            <input name="addresseeRead" th:field="${addressee.addresseeRead}" type="hidden">
            <input name="readTime" th:field="${addressee.readTime}" type="hidden">
        </div>
        <div class="weui-popup__modal">
            <div class="toolbar">
                <div class="toolbar-inner">
                    <a href="javascript:;" class="picker-button close-popup">关闭</a>
                    <h1 class="title">会议报名</h1>
                </div>
            </div>
            <div class="modal-content bgwhite">
            <textarea name="participantsName" placeholder="请输入姓名（格式：XXX,XXX,XXX 英文逗号分隔）"
                      class="weui-textarea w90 mauto plr15 ptb10" cols="30" rows="10"
                      th:field="*{addressee.participantsName}"></textarea>
                <div class="plr15 ptb10">
                    <a href="javascript:;" class="weui-btn weui-btn_primary close-popup" onclick="returnSign()">确定</a>
                </div>
            </div>
        </div>
    </form>
</div>

<!-- 回复Popup -->
<div id="replyPopup" class='weui-popup__container popup-bottom'>
    <form class="form-horizontal m" id="form-response-add">
        <div class="weui-popup__overlay">
            <input name="noticeId" th:field="${notice.noticeId}" type="hidden">
        </div>
        <div class="weui-popup__modal">
            <div class="toolbar">
                <div class="toolbar-inner">
                    <a href="javascript:;" class="picker-button close-popup">关闭</a>
                    <h1 class="title">回复</h1>
                </div>
            </div>
            <div class="modal-content bgwhite">
            <textarea name="responseContent" placeholder="请输入回复内容（必填）" class="weui-textarea w90 mauto plr15 ptb10"
                      type="text" rows="5" required></textarea>
                <div class="hr-line-dashed"></div>
                <div class="plr15 pb10">
                    <h4 class="mb5">附件</h4>
                    <input name="fileRoute" type="hidden" value="">
                    <input id="williamYe" type="file" class="mt10">
                </div>

                <div class="plr15 ptb10">
                    <a href="javascript:;" class="weui-btn weui-btn_primary close-popup" onclick="addResponse()">确定</a>
                </div>
            </div>
        </div>
    </form>
</div>

<script th:src="@{/res/notice/lib/jquery-2.1.4.js}"></script>
<script th:src="@{/res/notice/js/jquery-weui.js}"></script>
<script th:src="@{/res/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/res/bonorsoft/js/william-boot.js}"></script>
<script th:inline="javascript">
    var token = [[${token}]];
    var fileRoute = [[${file.fileRoute}]];
    var noticeType = [[${notice.noticeType}]];
    var partName = [[${addressee.participantsName}]];
    var prefix = "/sys/common/download";
    var noticeUrl = "/mobile/notice";
    window.onload = function () {
        if (!fileRoute) {
            document.getElementById("down-button").style.display = "none";
        }//判断有无附件，选择是否显示
        if (noticeType === "2") {
            document.getElementById("sign-button").style.visibility = "visible";
        } else {
            document.getElementById("sign-button").style.display = "none";
        }//判断是否会议通知，选择是否显示
        if (!partName) {
            document.getElementById("sign-yes").style.visibility = "visible";
            document.getElementById("sign-edit").style.display = "none";
        } else {
            document.getElementById("sign-edit").style.visibility = "visible";
            document.getElementById("sign-yes").style.display = "none";
        }//判断有无参会姓名，选择显示报名/修改
    };

    function downloadThis() {
        down_url = prefix + "/" + fileRoute;
        window.open(down_url);
    }

    function downloadThat(file) {
        down_url = prefix + "/" + file;
        window.open(down_url);
    }

    function returnSign() {
        save(noticeUrl+"/signUp", $('#form-signUp-add').serialize(), function (res) {
            if (res.success) {
                $.modal.close();
            }
        });
    }

    function addResponse() {
        save(noticeUrl + "/addResponse", $('#form-response-add').serialize(), function (res) {
            if (res.success) {
                $.modal.close();
            }
        });
    }

    function save(url, data, callback) {
        var config = {
            url: url,
            type: "post",
            dataType: "json",
            data: data,
            beforeSend: function (request) {
                request.setRequestHeader("X-Access-Token", token);
            }
        };
        $.ajax(config);
        $.toast("操作完成!");
        setTimeout(function () {
            window.location.reload();//刷新当前页面.
        }, 800)
    }

    function fileUpload(data, $dom) {
        $.ajax({
            url: '/sys/common/upload',
            data: data,
            type: 'POST',
            Accept: 'text/html;charset=UTF-8',
            cache: false,
            contentType:false,
            processData: false,
            beforeSend: function (request) {
                request.setRequestHeader("X-Access-Token",token);
            },
            success: function(res) {
                $($dom).val(res.message);
            },
            error: function(xhr) {
            }
        });
    }

    $('#williamYe').on('change.bs.fileinput ', function (e) {
        // 处理自己的业务
        if (this.files[0]) {
            const formData = new FormData();
            formData.append('file', this.files[0]);
            fileUpload(formData, $('input[name="fileRoute"]'));
        } else {
            $('input[name="fileRoute"]').val("");
        }
    });


</script>

</body>
</html>
